home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Personal Computer World 2009 February
/
PCWFEB09.iso
/
Software
/
Resources
/
Chat & Communication
/
Digsby build 37
/
digsby_setup.exe
/
lib
/
hmac.pyo
(
.txt
)
< prev
next >
Wrap
Python Compiled Bytecode
|
2008-10-13
|
2KB
|
76 lines
# Source Generated with Decompyle++
# File: in.pyo (Python 2.5)
def _strxor(s1, s2):
return ''.join(map((lambda x, y: chr(ord(x) ^ ord(y))), s1, s2))
digest_size = None
_secret_backdoor_key = []
class HMAC:
def __init__(self, key, msg = None, digestmod = None):
if key is _secret_backdoor_key:
return None
if digestmod is None:
import hashlib as hashlib
digestmod = hashlib.md5
if callable(digestmod):
self.digest_cons = digestmod
else:
self.digest_cons = lambda d = ('',): digestmod.new(d)
self.outer = self.digest_cons()
self.inner = self.digest_cons()
self.digest_size = self.inner.digest_size
if hasattr(self.inner, 'block_size'):
blocksize = self.inner.block_size
if blocksize < 16:
blocksize = 64
else:
blocksize = 64
ipad = '6' * blocksize
opad = '\\' * blocksize
if len(key) > blocksize:
key = self.digest_cons(key).digest()
key = key + chr(0) * (blocksize - len(key))
self.outer.update(_strxor(key, opad))
self.inner.update(_strxor(key, ipad))
if msg is not None:
self.update(msg)
def update(self, msg):
self.inner.update(msg)
def copy(self):
other = HMAC(_secret_backdoor_key)
other.digest_cons = self.digest_cons
other.digest_size = self.digest_size
other.inner = self.inner.copy()
other.outer = self.outer.copy()
return other
def digest(self):
h = self.outer.copy()
h.update(self.inner.digest())
return h.digest()
def hexdigest(self):
return []([ hex(ord(x))[2:].zfill(2) for x in tuple(self.digest()) ])
def new(key, msg = None, digestmod = None):
return HMAC(key, msg, digestmod)